package com.pk.platform.business.common.service.impl;

import java.util.List;

import com.pk.platform.business.common.dao.IClaDao;
import com.pk.platform.business.common.service.IClaService;
import com.pk.platform.business.common.vo.ClaVO;
import com.pk.platform.domain.common.Cla;
import com.pk.platform.util.constant.Constant;
import com.pk.platform.util.page.ListPage;
import com.pk.platform.util.page.Pager;

public class ClaServiceImpl implements IClaService {

	private IClaDao claDao;
	
	public ListPage queryCla(ClaVO clavo, Pager pager) {
		return claDao.queryCla(clavo, pager);
	}
	
	public void addClass(Cla cla)
	{
		claDao.add(cla);
		claDao.addOperateLog("新增班级", Constant.SUCCESSFUL, cla.getKindergarten());
	}
	
	public void updateClass(Cla cla)
	{
		Cla c = this.queryClassById(cla.getId());
		c.setClassName(cla.getClassName());
		c.setDebutDate(cla.getDebutDate());
		c.setClassType(cla.getClassType());
		claDao.addOperateLog("修改班级", Constant.SUCCESSFUL, c.getKindergarten());
	}
	
	public Cla queryClassById(String id)
	{
		return claDao.get(Cla.class, id);
	}
	
	public boolean delClass(String id)
	{
		Cla cla = this.queryClassById(id);
		if(cla.getChildSet().size() == 0)
		{
			claDao.addOperateLog("删除班级", Constant.SUCCESSFUL, cla.getKindergarten());
			claDao.delete(Cla.class, id);
			return true;
		}
		return false;
	}
	
	public List<Cla> queryClassList(String kgId)
	{
		return claDao.queryClassList(kgId);
	}

	public IClaDao getClaDao() {
		return claDao;
	}

	public void setClaDao(IClaDao claDao) {
		this.claDao = claDao;
	}

}
